import React, { useEffect, useState } from 'react';
import Lbxins from "../../../api/lbxin";
import { withRouter } from 'react-router-dom';
import MarkedP from "../../../components/common/markedP"
import { Spin } from 'antd';

const ArticalItem: React.FunctionComponent<any> = (props):any => {
  const [markedInfo, setmarkedInfo] = useState({})
  const [articalItemLoading, setarticalItemLoading] = useState(true)
  //default/getShareItemById/44
  useEffect(() => {
    Lbxins.get(`/default/getShareItemById/${props.location.state.id}`).then(res => {
      setarticalItemLoading(false)
      setmarkedInfo({...res.data[0],shareTopicTitle:props.location.state.shareTopicTitle})
    }).catch(error => {
      setarticalItemLoading(false)
      console.log(error,'error--console')
      
    })
  }, [])
  return (
    <Spin spinning={articalItemLoading}>
      <div className="contentBox">
        <MarkedP markedInfo={markedInfo} />
      </div>
    </Spin>
  );
};

export default withRouter(ArticalItem);
